//
//  NSDictionary+Sign.m
//  OAProject
//
//  Created by yhj on 2017/2/21.
//  Copyright © 2017年 cdnunion. All rights reserved.
//

#import "NSDictionary+Sign.h"

@implementation NSDictionary (Sign)

//   由两个参数  --- >    4个参数演变
/**
 

 "admin_name" = "yanghuijuan";     ----->>>>  "admin_name" = yanghuijuan;
                                              code = 02e1abb25cb1eddaad9cdc4ac7a0c0c5;
  code = "123456";                           timestamp = 1490239872;
                                             "vathome_key" = fc5b0f658224d825998c154d14eb2ae9;
**/

-(NSDictionary *)configParameters
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];

    // 获取当前帐号的密码
    NSString *code=newDict[@"code"];

    // 账号  密码  当前时间的时间戳  AppKey  采用md5加密   ---  获取加密后的密码字符串
    NSString *newCode=[NSString stringWithFormat:@"%@%@%ld%@",newDict[@"admin_name"],[Util md5String:code],(long)currentTimesStamp,kApp_Key];
    [newDict setValue:[Util md5String:newCode] forKey:@"code"];

//    NSString *key=[NSString stringWithFormat:@"%@%@",code,@"^Vangen-2006$"];
//    [newDict setValue:[Util md5String:key] forKey:@"vathome_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersAdd
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];

    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"add" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"add",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersDelete
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"delete" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"delete",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersDel
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"del" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"del",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}


-(NSDictionary *)configParametersRows
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"rows" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"rows",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersPriority
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"priority" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"priority",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersLevel_Rows
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"level_rows" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"level_rows",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersLevel_Users
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"users" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"users",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersStatus
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"status" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"status",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersLogs
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"logs" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"logs",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersRow
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"row" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"row",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersEdit
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"edit" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"edit",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersRefresh
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
     [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
//    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"refresh" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"refresh",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];

}

-(NSDictionary *)configParametersDeal
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"deal" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"deal",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersCancel
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"cancel" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"cancel",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersPublish
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"publish" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"publish",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersAcceptance
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"acceptance" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"acceptance",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersEvaluate
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"evaluate" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"evaluate",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersGetScore
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"get_score" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"get_score",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersSave
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"save" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"save",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}

-(NSDictionary *)configParametersLog
{
    // initWithDictionary:对应的类静态实例化方法
    NSMutableDictionary *newDict=[NSMutableDictionary dictionaryWithDictionary:self];

    // 获取当前时间的时间戳
    NSInteger currentTimesStamp=[[NSDate date]timeIntervalSince1970];

    [newDict setValue:MemberID forKey:@"member_id"];
    [newDict setValue:@(currentTimesStamp) forKey:@"timestamp"];
    [newDict setValue:[Util getUserDefaultObjectForKey:@"TToken"] forKey:@"token"];
    [newDict setValue:@"log" forKey:@"opt"];

    NSString *key=[NSString stringWithFormat:@"%@%@%ld",[Util getUserDefaultObjectForKey:@"TToken"],@"log",(long)currentTimesStamp];
    [newDict setValue:[Util md5String:key] forKey:@"secret_key"];

    return [NSDictionary dictionaryWithDictionary:newDict];
}
@end
